/*
 * L1Comparator.cpp
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#include "../../../include/core/comparator/L1Comparator.h"


double L1Comparator::getComparisonValue(SubstrateModel * substrate_model){
		double fitness = 0;
		vector<vector<double> > comp_displacements (positions.size());
		for(unsigned int i=0;i<positions.size();i++){
			comp_displacements[i] = vector<double> (2,0);
		}
		comp_displacements = substrate_model->get_displacement_list_at(positions);
		for(unsigned int i=0; i<positions.size(); i++){
			fitness += abs(comp_displacements[i][0] - displacements[i][0]);
			fitness += abs(comp_displacements[i][1] - displacements[i][1]);
		}
		return fitness/((double) data->get_n_data_points());
};
